/*
 * Created on 08.08.2006 by leck
 *
 */
package de.devisnik.eidle.flashlight;

import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;

import de.devisnik.eidle.EidleActivator;

public class FlashlightPreferences extends AbstractPreferenceInitializer {

	final static String KEY_GLOBAL_IMAGE_PATH = "global_image_path";
	final static String KEY_PRESENTATION_TIME = "presentation_time";
	final static String KEY_RELATIVE_DIAMETER = "relative_diameter";
	static final String KEY_SPOT_NUMBER = "spot_number";
	static final String KEY_USE_SCREENSHOT = "use_screenshot";

	public static void setGlobalImagePath(final String value) {
		getPreferences().setValue(KEY_GLOBAL_IMAGE_PATH, value);
	}

	public static String getGlobalImagePath() {
		return getPreferences().getString(KEY_GLOBAL_IMAGE_PATH);
	}

	public static boolean isUseScreenShot() {
		return getPreferences().getBoolean(KEY_USE_SCREENSHOT);
	}

	// @Override
	public void initializeDefaultPreferences() {
		getPreferences().setDefault(KEY_GLOBAL_IMAGE_PATH,
				EidleActivator.getDefault().getDataLocation());
		getPreferences().setDefault(KEY_PRESENTATION_TIME, 60);
		getPreferences().setDefault(KEY_RELATIVE_DIAMETER, 33);
		getPreferences().setDefault(KEY_SPOT_NUMBER, 1);
		getPreferences().setDefault(KEY_USE_SCREENSHOT, true);
	}

	private static Preferences getPreferences() {
		return FlashlightActivator.getDefault().getPluginPreferences();
	}

	/**
	 * @return the duration while a flash screen is shown (in seconds)
	 */
	public static int getPresentationTime() {
		return getPreferences().getInt(KEY_PRESENTATION_TIME);
	}

	public static void setPresentationTime(final int value) {
		getPreferences().setValue(KEY_PRESENTATION_TIME, value);
	}

	/**
	 * @return relative diameter (in percent)
	 */
	public static double getRelativeDiameter() {
		return getPreferences().getInt(KEY_RELATIVE_DIAMETER);
	}

	public static void setRelativeDiameter(final double value) {
		getPreferences().setValue(KEY_RELATIVE_DIAMETER, value);
	}

	public static int getSpotNumber() {
		return getPreferences().getInt(KEY_SPOT_NUMBER);
	}
}
